package com.zyq.ssyx.common.exception;

import com.zyq.ssyx.common.result.ResultCodeEnum;
import lombok.Data;

/**
 * @author clap of thunder
 * @date 2023-11-15 16:59
 * @description
 */
@Data
public class CustomException extends RuntimeException{

    /**异常状态码*/
    private Integer code;

    /**
     * @param :message,code
     * @description 根据错误信息和异常状态码返回
     * @date 2023/11/15 17:18
     */
    public CustomException(String message,Integer code) {
        super(message);
        this.code = code;
    }

    /**
     * @param :message,code
     * @description 接收枚举类型对象
     * @date 2023/11/15 17:18
     */
    public CustomException(ResultCodeEnum resultCodeEnum) {
        super(resultCodeEnum.getMessage());
        this.code = resultCodeEnum.getCode();
    }


    @Override
    public String toString() {
        return "CustomException{" +
                "code=" + code +
                '}';
    }
}
